<!DOCTYPE html>

<html xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div sec:authorize="isAuthenticated()">
    <h1>当前登录用户：<span sec:authentication="name"></span>&nbsp;&nbsp;当前角色：<span
            sec:authentication="principal.authorities"></span><br></h1>

    <div sec:authorize="hasRole('ROLE_admin')">
        <h1>this is admin role</h1>
    </div>
    <hr/>
    <div sec:authorize="hasRole('ROLE_user')">
        <h1>this is user role</h1>
    </div>
</div>
<div>
    <a href="/logout">注销</a>
</div>
</body>
</html>